package com.xd.clap.controller;

import com.xd.clap.entity.Orders;
import com.xd.clap.entity.request.OrderParam;
import com.xd.clap.entity.request.PageParam;
import com.xd.clap.entity.response.Result;
import com.xd.clap.services.OrderService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Resource
    private OrderService os;

    /**
     *创建订单
     */
    @PostMapping("/createOrder")
    public Result createOrder(@RequestBody OrderParam orderParam) {
        return os.createOrder(orderParam);
    }

    /**
     *查询所有订单
     */
    @GetMapping("/getOrdersPage")
    public Result getOrdersPage(PageParam pageParam) {
        return os.getOrdersPage(pageParam);
    }

    /**
     *查询用户的订单
     */
    @GetMapping("/getOrders")
    public Result getOrders(PageParam pageParam) {
        return os.getOrders(pageParam);
    }

    /**
     * 修改订单状态
     */
    @PostMapping("/updateState")
    public Result updateState(@RequestBody Orders orders){
        return os.updateState(orders);
    }


}
